package HashSet_package;

import java.util.LinkedHashSet;

public class LinkedHashSet_demo {
    public static void main(String[] args) {
        //1、创建三个学生对象
        Student s1 = new Student("zhangsan", 23);
        Student s2 = new Student("lisi", 24);
        Student s3 = new Student("wangwu", 25);
        Student s4 = new Student("zhangsan", 23);

        //2、创建集合用来添加学生
        LinkedHashSet<Student> lhs = new LinkedHashSet<>();

        //3、添加元素
        System.out.println(lhs.add(s1));
        System.out.println(lhs.add(s2));
        System.out.println(lhs.add(s3));
        System.out.println(lhs.add(s4));

        //4、打印集合，反映添加的先后顺序
        System.out.println(lhs);
    }
}
